Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mng 11 html quiz template #19

Merged
merged 13 commits into from
Jan 7, 2021
Merged

Mng 11 html quiz template #19

merged 13 commits into from
Jan 7, 2021

Conversation

daria305
Copy link
Collaborator

@daria305 daria305 commented Jan 6, 2021

QuizPage.js need to be connected with generator, for now it uses dummy variables, and reads the same question all over again. ( I will do it when Marisz will finish the generator)

  • For more general changes, I changed a little App.css to use a custom style for the current view layout, it was using # pokequiz-app for grid layout for the start page, w don’t need this in the quiz page. But we need #pokequiz-app to switch the views. Now each page needs to add its style during rendering.
  • All styles change during the runtime, are stored in appSettings.js in for of a dictionary, it will be easier to find them or change during styling.

General about how it works:
StartButton is triggering the RenderQuizPage() function. This function uses template stored in index.html and render basic elements, like header title, setting up question number to 1. Next renderNextQusetion is called to generate first question according to the selected game mode.
Variables used during the game duration, like the mode or a generator, for now, are stored as module variables, this way is easily reachable when a new question is generated. Of course, we can still think about a better way of handling game status and data.
If the generator returned all questions == user answered all of then renderNextQuestion is no longer rendering the new quiz page. Later we will connect it to the results page.
Styles for questions and answers are added according to the mode, we will see during the styling if they are enough to achieve a good result.

What to be done next:

  • I haven’t started adding the progress bar, but it should not be the problem – the div for the progress bar is rendered at the beginning and not refreshed, the same for the clock.
  • Connect with a generator, everything is ready to receive the object structure I provided in the task.
  • Add saving results of the game, that will be used for summary and the hall of fame.
  • Timer.
  • redirection to the summary page

src/app/App.js Outdated Show resolved Hide resolved
// listen for an answer selection
const answersOptions = [...quizBody.querySelector(".quiz-answers-list").children]
for (let option of answersOptions) {
option.addEventListener("mouseup", function selectEventFunc() {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mouseup? czemu nie click?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a, dobra, bo może ktoś by się w ostatniej chwili cofnął i jednak chciał ściągnąć myszkę z odpowiedzi. Make sense 😌

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly, that was the idea behind

}

//TODO dummy function to be removed after generator is added
const getNextQuestion = (mode) => {
Copy link
Owner

@lukaszdutka lukaszdutka Jan 6, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

be aware of that this function is going to be async

questionNum: 1,
}
setupPageTitle(mode);
CURRENT_MODE = mode;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe set it at the top of the function and then only refer to CURRENT_MODE?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right, I changed it in the last line, and forgot here

Comment on lines 217 to 218
const quizBody = document.querySelector('#quiz-body');
const quizTemplate = document.getElementById('quiz-template');
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't querySelector('#quiz-body') the same as getElementById('quiz-body')? I am not sure, just asking 😄

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup, it would be the same, i could just use querySelector everywhere

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, I think it is better to use getElementById - because you know that you are searching for specific id and not for any other items. Internet says "it depends", see here:
https://stackoverflow.com/questions/26848289/javascript-queryselector-vs-getelementbyid

@daria305 daria305 marked this pull request as ready for review January 7, 2021 11:43
@daria305
Copy link
Collaborator Author

daria305 commented Jan 7, 2021

Maybe we can merge it to dev? I connected it to Agata's functions and added SELECTED_MODE variable, so we can select and run the game, for now with the one dummy question. I will open new task for me to connect it after generator is ready.

@lukaszdutka lukaszdutka merged commit 1352a01 into dev Jan 7, 2021
@lukaszdutka lukaszdutka deleted the MNG-11-HTML-quiz-template branch January 7, 2021 14:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants